//
//  AppInfo.m
//  BaoVn
//
//  Created by Le Anh Tai on 11/16/14.
//  Copyright (c) 2014 Le Anh Tai. All rights reserved.
//

#import "AppInfo.h"

@implementation AppInfo

static AppInfo *_shared;

+ (AppInfo *)shared
{
    if (_shared == nil)
    {
        _shared = [[AppInfo alloc] init];
    }
    
    return _shared;
}

- (instancetype)init
{
    if (self = [super init])
    {
        [self initializedNewsType];
    }
    
    return self;
}

- (void)initializedNewsType
{
    NSNumber *type = [[NSUserDefaults standardUserDefaults] objectForKey:NEW_TYPES_KEY];
    if (type == nil)
    {
        type = [NSNumber numberWithInt:NewsTypeItem];
    }
    
    _newsType = [type intValue];
}

- (void)setNewsType:(NewsType)newsType
{
    _newsType = newsType;
    
    [[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithInt:_newsType] forKey:NEW_TYPES_KEY];
}

@end
